<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >
  <!--Style for the tab item in the ribbon.-->
  <Style TargetType="{x:Type TabItem}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
    <Setter Property="TextElement.Foreground" Value="{StaticResource NormalForegroundBrush}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabItem}">
            <Border 
                  Padding="3,2,3,5"
                  Name="border"
                  SnapsToDevicePixels="True"
                  Margin="2,0,2,-1"
                  BorderThickness="1,1,1,0" 
                  CornerRadius="3,3,0,0"
                  >
                <ContentPresenter Grid.Column="1" x:Name="ContentSite"
                     VerticalAlignment="Center"
                     HorizontalAlignment="Center"
                     ContentSource="Header"
                     Margin="7,2,12,2"                    
                     RecognizesAccessKey="True" />
            </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsSelected" Value="True">
              <Setter Property="Panel.ZIndex" Value="1000"/>
              <Setter TargetName="border" Property="Background" Value="{StaticResource TabItemBackgroundBrush}"/>
              <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}"/>
              <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}"/>
              <Setter TargetName="border" Property="BorderThickness" Value="1,1,1,0" />
              <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="False"/>
                <Condition Property="IsMouseOver" Value="True"/>
              </MultiTrigger.Conditions>
              <Setter Property="Background" TargetName="border" Value="{StaticResource HighlightBackgroundBrush}"/>
              <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource PressedBorderBrush}"/>
            </MultiTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <!--Style for the tab in the ribbon.-->
  <Style TargetType="TabControl">
    <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
    <Setter Property="TextElement.Foreground" Value="{StaticResource NormalForegroundBrush}"/>
    <Setter Property="Control.Padding" Value="4,8,4,4"/>
    <Setter Property="Border.BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
    <Setter Property="Border.Background" Value="{StaticResource NormalBackgroundBrush}"/>
    <Setter Property="Control.HorizontalContentAlignment" Value="Center"/>
    <Setter Property="Control.VerticalContentAlignment" Value="Center"/>
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabControl}">
          <Grid
              ClipToBounds="True"
              SnapsToDevicePixels="True"
              KeyboardNavigation.TabNavigation="Local">
            <Grid.ColumnDefinitions>
              <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TabPanel
                Margin="4,4,4,0"
                IsItemsHost="True"
                Name="HeaderPanel"
                Panel.ZIndex="1"
                KeyboardNavigation.TabIndex="1"
                Grid.Column="0"
                Grid.Row="0" />
            <Border
                SnapsToDevicePixels="True"
                Background="{DynamicResource NormalBackgroundBrush}" 
                BorderBrush="{StaticResource NormalBorderBrush}"
                BorderThickness="1" 
                Name="ContentPanel"
                CornerRadius="3" 
                KeyboardNavigation.TabIndex="2"
                KeyboardNavigation.TabNavigation="Local"
                KeyboardNavigation.DirectionalNavigation="Contained"
                Grid.Column="0"
                Grid.Row="1">
                  <ContentPresenter
                      ContentSource="SelectedContent"
                      Margin="{TemplateBinding Control.Padding}"
                      Name="PART_SelectedContentHost"
                      SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                      ContentTemplate="{TemplateBinding TabControl.SelectedContentTemplate}"
                      Content="{TemplateBinding TabControl.SelectedContent}" />
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="UIElement.IsEnabled" Value="False">
              <Setter Property="TextElement.Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>